using System;
using Sinacor.Infra.Common;
using System.Collections.Generic;
using Sinacor.Service.Infra.AuthorizationService.Service.DataContract.Request;
using Sinacor.Service.Infra.AuthorizationService.BusinessEntity;

namespace Sinacor.Service.Infra.AuthorizationService.Service.ServiceImplementation.Translator
{
    /// <summary>
    /// Classe tradutora entre objetos UpdatePolicyRequest e Policy
    /// </summary>
    public class BehaviorPolicyToBehaviorPolicyResponse :
            BaseTranslator<DataContract.Response.BehaviorPolicyResponse, BusinessEntity.BehaviorPolicy,
            List<DataContract.Response.BehaviorPolicyResponse>,List<BusinessEntity.BehaviorPolicy>>
    {
        public override DataContract.Response.BehaviorPolicyResponse Translate(BusinessEntity.BehaviorPolicy from)
        {
            if (from == null)
                return null;

            DataContract.Response.BehaviorPolicyResponse to = new DataContract.Response.BehaviorPolicyResponse();

            to.CompanyId = from.CompanyId;

            to.RoleId = from.RoleId;

            if (from.AssociatedPolicy != null)
            {
                PolicyToPolicyResponse policyTranslator = new PolicyToPolicyResponse();
                to.AssociatedPolicy = policyTranslator.Translate(from.AssociatedPolicy);
            }
            else
                to.AssociatedPolicy = null;
            
            to.IsEditable = from.IsEditable;
            to.IsVisible = from.IsVisible;            

            return to;
        }



    }
}

